package edu.washington.cs.sounddetector.server.api.methodresult;

import edu.washington.cs.sounddetector.server.api.MethodResult;
import edu.washington.cs.sounddetector.server.api.method.UnregisterReceiverPhone;

public class UnregisterReceiverPhoneResult extends MethodResult<UnregisterReceiverPhone>
{

    private String phoneId;

    private UnregisterReceiverPhoneResult(boolean successful, FailureReason reason, String phoneId)
    {
        super(successful, reason);
        this.phoneId = phoneId;
    }

    private UnregisterReceiverPhoneResult()
    {
        this(true, null, null);
    }

    /**
     * @return if {@link #isSuccessful()} == true, returns null, otherwise returns the phoneId of
     *         the phone that failed to be unregistered.
     */
    public String getPhoneId()
    {
        return phoneId;
    }

    public static UnregisterReceiverPhoneResult success()
    {
        return new UnregisterReceiverPhoneResult(true, null, null);
    }

    public static UnregisterReceiverPhoneResult failurePhoneDoesNotExist(String phoneId)
    {
        return new UnregisterReceiverPhoneResult(false, FailureReason.PHONE_DOES_NOT_EXIST, phoneId);
    }
}
